<?php
namespace app\api\controller;
use think\Controller;
use think\Db;

class Look extends  Controller
{
	/**
	*查看投票进度
	*/
	public function schedule()
	{
		if(request()->isPost())
		{
			$post = file_get_contents("php://input");
			$data = json_decode($post,true);

			if(!isset($data['sign']) || empty($data['sign']))
			{
				$info['code'] = -1;
	        	$info['message'] = '缺少查看条件';
	        	return json_encode($info,JSON_UNESCAPED_UNICODE);
			}
			$sign = $data['sign'];

			//查询数据
			if($sign == 'personal'  ) //先进个人  
			{
				$res = Db::query("select id,image,name,unit,personal as num from tp_candidate");
				$info['code'] = 0;
				$info['data'] 	= $res;
				return json_encode($info,JSON_UNESCAPED_UNICODE);
			}elseif($sign == 'pacesetter') //师德标兵
			{
				$res = Db::query("select id,image,name,unit,pacesetter as num from tp_candidate where  sign=1 ");
				$info['code'] = 0;
				$info['data'] 	= $res;
				return json_encode($info,JSON_UNESCAPED_UNICODE);
			}else
			{
				$info['code'] = -1;
				$info['message'] 	= '标识出错';
				return json_encode($info,JSON_UNESCAPED_UNICODE);
			}
		}else
		{
			$info['code'] = -1;
        	$info['message'] = '非法方式传输';
        	return json_encode($info,JSON_UNESCAPED_UNICODE);
		}
	}



}
